package com.lonwin.inspectionmanagement.mvp.ui.adapter;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.MotionEvent;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
//import com.library.flowlayout.FlowLayoutManager;
//import com.library.flowlayout.SpaceItemDecoration;
import com.lonwin.inspectionmanagement.R;
import com.lonwin.inspectionmanagement.app.utils.SpaceItemDecoration;
import com.lonwin.inspectionmanagement.mvp.model.entity.bean.ConfigBean;

import java.util.List;

public class CruiseSearchAdapter extends BaseQuickAdapter<ConfigBean.RiverDatasBean,BaseViewHolder> {
//    private FlowLayoutManager flowLayoutManager;
    private CruiseSearchItemAdapter cruiseSearchItemAdapter;
    public CruiseSearchAdapter(@Nullable List<ConfigBean.RiverDatasBean> data) {
        super(R.layout.cruise_search_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ConfigBean.RiverDatasBean item) {
       helper.setText(R.id.search_item_title,item.getName());
//        flowLayoutManager=new FlowLayoutManager();
        helper.<RecyclerView>getView(R.id.search_item_RecyclerView).setLayoutManager(new GridLayoutManager(mContext,2));
//        helper.<RecyclerView>getView(R.id.search_item_RecyclerView).addItemDecoration(new SpaceItemDecoration(dp2px(10)));
        cruiseSearchItemAdapter=new CruiseSearchItemAdapter(item.getChildren());
        helper.<RecyclerView>getView(R.id.search_item_RecyclerView).setAdapter(cruiseSearchItemAdapter);

    }
    /**
     * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
     * @param dpValue 虚拟像素
     * @return 像素
     */
    public  int dp2px(float dpValue) {
        return (int) (0.5f + dpValue * Resources.getSystem().getDisplayMetrics().density);
    }
}
